package com.firesyde.gwt.persistence.guice.hibernate;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

import com.google.inject.Provider;

/**
 * Simple provider that returns a hibernate session
 * @author dan
 *
 */
public class HibernateSessionProvider implements Provider<Session> {
	
	private SessionFactory sessionFactory;

	public HibernateSessionProvider(Configuration config) {
		sessionFactory = config.buildSessionFactory();
	}
	
	public Session get() {
		return sessionFactory.openSession();
	}

}
